home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6417 < prev    next >
Encoding:
Text File  |  1996-08-05  |  760 b   |  33 lines

  1. Path: ix.netcom.com!netnews
  2. From: Manuel Hernandez <ManuelHe@ix.netcom.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: resetting a character array
  5. Date: 8 Feb 1996 04:09:36 GMT
  6. Organization: Netcom
  7. Message-ID: <4fbt20$4o3@cloner3.netcom.com>
  8. NNTP-Posting-Host: irv-ca15-08.ix.netcom.com
  9. X-NETCOM-Date: Wed Feb 07  8:09:37 PM PST 1996
  10.  
  11. This must be a total beginners question. How do you reset
  12. a character array so you can enter a string into a variable 
  13. over and over again? This is what I have so far.
  14.  
  15. void main()
  16. {  
  17.    char name[20];
  18.    char answer;
  19.             
  20.    do
  21.      {  
  22.     cout << "Enter a name" << endl;
  23.     cin.getline(name,20);
  24.                 
  25.     cout << name << " is a nice name. Enter another? " << endl;
  26.     cin >> answer;
  27.                     
  28.      }
  29.     while (answer == 'y');
  30.     return;
  31. }            
  32.      
  33.